package com.tbit.main.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.tbit.main.dao.core.MachineBorrowDao;
import com.tbit.main.pojo.MachineBorrow;
import com.tbit.main.pojo.VO.LongOrderTimeVO;
import com.tbit.main.service.MachineBorrowService;
import com.tbit.main.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service("machineBorrowService")
public class MachineBorrowServiceImpl implements MachineBorrowService {
    @Autowired
    private MachineBorrowDao machineBorrowDao;

    @Override
    public MachineBorrow getByMachineId(Integer machineId) {
        return machineBorrowDao.getByMachineId(machineId);
    }

    @Override
    public List<MachineBorrow> getByMachineIds(List<Integer> machineIds) {
        return CollUtil.isEmpty(machineIds)
                ? Collections.emptyList()
                : machineBorrowDao.getByMachineIds(StringUtil.getListString(machineIds));
    }

    @Override
    public List<MachineBorrow> getByAccountId(Integer accountId) {
        return machineBorrowDao.getByAccountId(accountId);
    }

    @Override
    public List<MachineBorrow> getByRegionId(List<Integer> regionId) {
        return machineBorrowDao.getByRegionId(StringUtil.getListString(regionId));
    }

    @Override
    public List<MachineBorrow> getAll() {
        return machineBorrowDao.getAll();
    }

    @Override
    public List<Map<String, Object>> getGroupByAccountId() {
        return machineBorrowDao.getGroupByAccountId();
    }

    @Override
    public List<Map<String, Object>> getGroupByRegionId(List<Integer> regionId) {
        return machineBorrowDao.getGroupByRegionId(StringUtil.getListString(regionId));
    }

    @Override
    public Integer getByParkPointId(Integer parkPointId) {
        return machineBorrowDao.getByParkPointId(parkPointId);
    }

    @Override
    public Integer getByAccountIdCount(Integer accountId) {
        return machineBorrowDao.getByAccountIdCount(accountId);
    }

    @Override
    public MachineBorrow getByUserId(Integer userId) {
        return machineBorrowDao.getByUserId(userId);
    }

    @Override
    public List<Integer> getExist(List<Integer> list) {
        return machineBorrowDao.getExist(list);
    }

    /**
     * 查询设备借车时长
     * @param machineIdList 设备id
     * @return List<LongOrderTimeVO>
     */
    @Override
    public List<LongOrderTimeVO> getLongOrderTime(List<Integer> machineIdList) {
        return machineBorrowDao.getLongOrderTime(machineIdList);
    }
}  